import java.util.HashMap;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 强仔
 * Date: 2022-05-22
 * Time: 9:03
 */


public class Main {
    /**
     *  1. 微信红包
     *  https://www.nowcoder.com/practice/fbcf95ed620f42a88be24eb2cd57ec54?tpId=49&&tqId=29311&rp=1&ru=/activity/oj&qru=/ta/2016test/question-ranking
     *  HashMap 求元素出现的次数
     */
    public int getValue(int[] gifts, int n) {
        HashMap<Integer, Integer> map = new HashMap<>();
        int mid = n/2;
        for (int elem : gifts) {
            if(map.get(elem) == null){
                map.put(elem, 1);
            }else {
                int value = map.get(elem);
                if(value + 1 > mid ){
                    return elem;
                }
                map.put(elem, value+1);
            }
        }
        return 0;
    }

    /**
     *  2. 计算字符串的距离
     * 动态规划解决
     *
     *
     */

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();
        int row = s1.length() + 1;
        int col = s2.length() + 1;
        int[][] F = new int[row][col];
        for (int i = 0; i < col; i++) {
            F[0][i] = i;
        }
        for (int i = 1; i < row; i++) {
            F[i][0] = i;
        }

        for (int i = 1; i < row; i++) {
            for (int j = 1; j < col; j++) {
                if(s1.charAt(i - 1) == s2.charAt(j - 1)){
                    F[i][j] = F[i - 1][j - 1];
                }else {
                    F[i][j] = Math.min(Math.min(F[i - 1][j - 1], F[i - 1][j]), F[i][j - 1]) + 1;
                }
            }
        }
        System.out.println(F[row - 1][col - 1]);
    }
}
